package com.bawei.mvvm.respository

import androidx.lifecycle.LiveData
import com.bawei.mvvm.db.AppDataBase
import com.bawei.mvvm.entity.BannerData
import com.bawei.mvvm.entity.Goods
import com.bawei.mvvm.entity.User
import com.bawei.mvvm.http.ApiResponse
import com.bawei.mvvm.http.ApiService
import com.bawei.mvvm.http.RetrofitManager
import okhttp3.RequestBody
import retrofit2.Retrofit
import retrofit2.http.Body
import retrofit2.http.Query
import javax.inject.Inject

class MainRepository @Inject constructor(var apiService: ApiService){
    //网络请求数据
    fun getBanners(): LiveData<ApiResponse<MutableList<BannerData>>>{
       return apiService.getBanners()
    }
    //网络请求数据
    fun getGoods(category_id:Int, currentPage:Int, pageSize:Int): LiveData<ApiResponse<MutableList<Goods>>>{
        return apiService.getGoods(category_id, currentPage, pageSize)
    }

    //插入轮播图数据
    fun insertBanner(bannerData: BannerData){
        AppDataBase.getInstance()?.getBannerDao()?.insert(bannerData)
    }
    //查询数据库
    fun getBannersFormDB():MutableList<BannerData>?{
        return AppDataBase.getInstance()?.getBannerDao()?.select()
    }



}